Communication method and device, electronic equipment and medium

By receiving routing network information in the cascade router settings, counting the number of sub-routers and performing pre-network holes, the problem that terminal devices under different sub-routers cannot communicate directly is solved, and communication efficiency and real-time are improved.

CN120050227APending Publication Date: 2025-05-27ZHEJIANG UNIVIEW TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311600199.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-27
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

In the cascading router settings, terminal devices under different sub-routers cannot communicate directly through the LAN and need to be drilled through the network, resulting in inefficient communication.

Method used

By receiving the routing network information sent by the sub-router, counting the number of sub-routers, and when at least two sub-routers are detected, they are pre-controlled to perform network hole punching and record hole punching information so that the terminal device can communicate directly based on the hole punching information.

Benefits of technology

It improves the real-time and efficiency of communication of terminal devices under different sub-routers, and avoids the waste of time for temporary network holes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120050227A_ABST
    Figure CN120050227A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a communication method and device, electronic equipment and a medium. The method comprises the following steps: receiving routing network information sent by sub-routers in the cascade router, and counting the number of the sub-routers according to the routing network information; if the number of the sub-routers is at least two, for any two sub-routers, controlling the two sub-routers to perform network holing; if the network holing of the two sub-routers succeeds, recording holing information so as to control the terminal devices under the two sub-routers to communicate according to the holing information; wherein the holing information comprises an incidence relation of the two sub-routers and routing network information. According to the scheme, network holing can be carried out in advance for different sub-routers, and the holing information is recorded, so that temporary holing is not needed when communication needs to be carried out when terminal equipment is connected under different sub-routers subsequently, communication is carried out directly through the pre-network holing link according to the holing information, and the real-time performance and convenience of communication are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technologies, and in particular, to a communication method, apparatus, electronic device, and medium. Background Art

[0002] At present, people's living conditions have improved significantly compared to before, with larger work and living areas. At the same time, the requirements for the coverage of routers have gradually increased. Using a conventional routing scheme, the signal in some rooms is often very poor due to the small coverage of the router. How to enhance the wireless signal, improve the network speed, and enhance the Internet access experience has become a rigid demand for people.

[0003] Currently, routers can be cascaded to increase the coverage of the routing and connect more terminal devices to access the Internet. For example, a home router is set up at home, and other sub-routers are connected under the home router, such as connecting more than two sub-routers, so as to increase the coverage of the router. However, in this case, the terminal devices under different sub-routers cannot communicate through the local area network and can only communicate by temporarily performing network hole punching, which takes a long time and affects the communication efficiency. Summary of the Invention

[0004] Embodiments of this application provide a communication method, apparatus, electronic device, and medium to improve the real-time performance and efficiency of communication between terminal devices under different sub-routers.

[0005] According to one aspect of this application, a communication method is provided. The method includes:

[0006] Receiving routing network information sent by a sub-router in a cascaded router, and counting the number of sub-routers according to the routing network information;

[0007] If the number of sub-routers is at least two, for any two sub-routers, controlling the two sub-routers to perform network hole punching;

[0008] If the network hole punching of the two sub-routers is successful, recording the hole punching information to control the terminal devices under the two sub-routers to communicate according to the hole punching information; where the hole punching information includes the association relationship between the two sub-routers and the routing network information.

[0009] According to one aspect of this application, a communication apparatus is provided. The apparatus includes:

[0010] An information receiving module, configured to receive routing network information sent by a sub-router in a cascaded router, and count the number of sub-routers according to the routing network information;

[0011] A network hole punching control module, which is used to control any two sub-routers to perform network hole punching if the number of the sub-routers is at least two;

[0012] A hole punching information recording module, which is used to record hole punching information if the network hole punching of two sub-routers is successful, so as to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information.

[0013] According to another aspect of the present application, there is provided an electronic device, which includes:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the communication method of any embodiment of the present application.

[0017] According to another aspect of the present application, there is provided a computer-readable storage medium, which stores computer instructions for causing a processor to implement the communication method of any embodiment of the present application when executed.

[0018] The technical solution of the embodiment of the present application receives the routing network information sent by the sub-routers in the cascaded router, and counts the number of the sub-routers according to the routing network information; if the number of the sub-routers is at least two, then for any two sub-routers, control the two sub-routers to perform network hole punching; if the network hole punching of two sub-routers is successful, record the hole punching information, so as to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information. The above solution pre-controls at least two sub-routers to punch holes and records the hole punching information when detecting that there are at least two sub-routers, so that when the terminal devices under different sub-routers need to communicate, they can directly communicate according to the hole punching information through the pre-punched link, without first performing network hole punching to establish a communication link and then communicating, which improves the real-time performance and communication efficiency of communication.

[0019] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easily understood through the following description. Description of the Drawings

[0020] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required in the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.

[0021] Figure 1 is a flowchart of a communication method provided in Embodiment 1 of the present application;

[0022] Figure 2 is a communication network diagram provided in Embodiment 1 of the present application;

[0023] Figure 3 is a schematic diagram of recording routing network information provided in Embodiment 1 of the present application;

[0024] Figure 4 is a schematic diagram of recording hole punching information provided in Embodiment 1 of the present application;

[0025] Figure 5 is a flowchart of a communication method provided in Embodiment 2 of the present application;

[0026] Figure 6 is a schematic diagram of recording terminal network information provided in Embodiment 2 of the present application;

[0027] Figure 7 is a schematic diagram of a communication network provided in Embodiment 3 of the present application;

[0028] Figure 8 is a schematic diagram of the structure of a communication device provided in Embodiment 4 of the present application;

[0029] Figure 9 is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application. Detailed implementation manners

[0030] To enable those skilled in the art to better understand the solutions of the present application, the following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0031] It should be noted that the terms "first", "second", "third", "fourth", "actual", "preset", etc. in the description, claims and the above-mentioned drawings of this application are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products or devices.

[0032] Embodiment 1

[0033] Figure 1 It is a flowchart of a communication method provided for Embodiment 1 of this application. The embodiments of this application are applicable to the situation of terminal device communication. Typically, it is applicable to the situation where terminal devices under different sub-routers at the same level of a cascaded router communicate. This method can be executed by a communication device, which can be implemented in the form of hardware and / or software, and the communication device can be configured in an electronic device. As Figure 1 shown, this method includes:

[0034] S110. Receive the routing network information sent by the sub-router in the cascaded router, and count the number of sub-routers according to the routing network information.

[0035] Among them, the cascaded router can be multiple interconnected routers. The router connected to the external network in the cascaded router is the parent router, and the router that is not directly connected to the external network but is connected to the parent router is the sub-router. The sub-router can be a router with storage function. Exemplarily, as Figure 2 shown, the parent router is connected to the cloud server and directly accesses the external network. At least one sub-router can be connected under the parent router. For example, in Figure 2, the parent router is connected to two sub-routers. Terminal devices can be connected under the sub-routers. The terminal devices can be image collectors, mobile phones, tablets, computers, smart wearable devices, etc. Figure 2 IPC10, IPC11, and IPC20 in Figure 2 are intelligent image collectors, and Phone1 is a mobile phone. The sub-router can also be connected to a lower-level sub-router, such as Figure 2The sub-router 1 and sub-router 2 therein are routers at the same level. If there are sub-routers connected below sub-router 1 and sub-router 2, the sub-routers connected below are routers at the same level. The sub-routers in the embodiments of the present application can be sub-routers at the same level or sub-routers between different levels. The solution in the embodiments of the present application can be executed by Figure 2 the cloud server therein. The routing network information can include the local area network address and port of the sub-router, that is, the IP address and port of the sub-router, as well as the public network address and port, that is, the IP address and port of the parent router.

[0036] Exemplarily, each sub-router can communicate with the cloud server, upload the routing network information of the sub-router, and regularly send keep-alive information to the cloud server so that the cloud server can determine the online status of the sub-router. The cloud server records the routing network information of each sub-router. Exemplarily, as Figure 3 shown, the sub-router 1 sends a packet to the address of the cloud server, 18.181.0.31:1234 is the destination address, and 192.168.0.11:4321 is the source address. The network address 192.168.0.11:4321 of the sub-router is converted through the address of the parent router to the public network address 155.99.25.11:4321, and accesses the destination address 18.181.0.31:1234 of the cloud server through the public network address. The session of the sub-router - cloud server is recorded on the NAT network, the source address is 192.168.0.11:4321, the converted public network address is 155.99.25.11:4321, and the destination address is 18.181.0.31:1234. The cloud server records the routing network information of the sub-router, including the source address 192.168.0.11:4321 and the public network address 155.99.25.11:4321. Among them, the number after ":" in the address corresponds to the port number. The same applies to sub-router 2. The cloud server counts the number of sub-routers that can communicate according to the recorded routing network information of the sub-routers. For example, if there are two sub-routers communicating with the cloud server and sending routing network information respectively, and the cloud server records two different routing network information, it is determined that the number of sub-routers is two.

[0037] S120. If the number of the sub-routers is at least two, then for any two sub-routers, control the two sub-routers to perform network hole punching.

[0038] Exemplarily, if the number of sub - routers statistically obtained by the cloud server is at least two, then for any two of the sub - routers, control the two sub - routers to perform network hole punching. Exemplarily, it is possible to traverse at least two sub - routers, determine whether the sub - router has performed network hole punching with other sub - routers respectively. If there is another sub - router that has not performed network hole punching with the currently traversed sub - router, then control the two sub - routers to perform network hole punching. If all other sub - routers have performed network hole punching with the previously traversed sub - router, then traverse the next sub - router. If the session link between two sub - routers that have already performed network hole punching has been in a normal established state, the two sub - routers will not perform network hole punching again.

[0039] S130. If the network hole punching of two sub - routers is successful, record the hole - punching information to control the terminal devices under the two sub - routers to communicate according to the hole - punching information; wherein, the hole - punching information includes the association relationship between the two sub - routers and the routing network information.

[0040] Exemplarily, if the network hole punching of two sub - routers is successful, report a message indicating successful network hole punching to the cloud server, and the cloud server records the hole - punching information. The hole - punching information includes the association relationship between the two sub - routers and the routing network information, that is, record which two sub - routers have successfully performed network hole punching, and the routing network information of the two sub - routers that have successfully performed network hole punching. Exemplarily, as Figure 4 shown, the cloud server records the association relationship between the two sub - routers that have completed network hole punching, such as Figure 4 in which sub - router 1 and sub - router 2 are associated, and records the routing network information of the two sub - routers. Since the network hole punching of the two sub - routers is successful, the session between sub - router 1 and the cloud server becomes a session in which sub - router 1 accesses the public network address of sub - router 2, and the session between sub - router 2 and the cloud server becomes a session in which sub - router 2 accesses the public network address of sub - router 1. At the same time, the hole - punching information is respectively recorded on the two sub - routers. As Figure 4 shown in, sub - router 1 records the local area network address of sub - router 1 and the public network address of sub - router 2, and sub - router 2 records the local area network address of sub - router 2 and the public network address of sub - router 1. Subsequently, when terminal devices under different sub - routers need to communicate, it is possible to directly determine whether the sub - router to which the terminal device is connected has successfully performed network hole punching according to the hole - punching information recorded on the cloud server. If it has successfully performed network hole punching, communicate according to the hole - punching information recorded on the cloud server.

[0041] In the embodiments of the present application, the two sub - routers include a first sub - router and a second sub - router;

[0042] Correspondingly, for any two sub - routers, notifying the two sub - routers to perform network hole punching includes:

[0043] Send the routing network information of the second sub-router to the first sub-router, and send the routing network information of the first sub-router to the second sub-router;

[0044] Notify the first sub-router to perform network hole punching based on the routing network information of the second sub-router, and / or notify the second sub-router to perform network hole punching based on the routing network information of the first sub-router.

[0045] Exemplarily, the two sub-routers may include a first sub-router and a second sub-router. As Figure 2 shown, the first sub-router is sub-router 1, and the second sub-router is sub-router 2. The cloud server sends the routing network information of the second sub-router to the first sub-router, and sends the routing network information of the first sub-router to the second sub-router. The cloud server may notify the first sub-router to initiate network hole punching based on the routing network information of the second sub-router, may also notify the second sub-router to initiate network hole punching based on the routing network information of the first sub-router, or may notify the first sub-router and the second sub-router to initiate network hole punching simultaneously. Taking the process of notifying the first sub-router to perform network hole punching as an example, the specific process of network hole punching is introduced: The first sub-router sends communication data to the second sub-router based on the routing network information of the second sub-router. At this time, the second sub-router has not communicated with the first sub-router, so it will discard the communication data sent by the first sub-router. At the same time, the first sub-router saves the record that the first sub-router has sent communication data to the second sub-router. At this time, the cloud server notifies the second sub-router to send communication data to the first sub-router based on the routing network information of the first sub-router. Since the first sub-router has a record of sending communication data to the second sub-router, it will receive the communication data sent by the second sub-router. At this time, the network hole punching between the first sub-router and the second sub-router is successful.

[0046] In the embodiment of the present application, after recording the hole punching information, the method further includes:

[0047] Send keep-alive control information to the first sub-router and the second sub-router, so that the first sub-router sends keep-alive information to the second sub-router at a preset frequency, and the second sub-router sends keep-alive information to the first sub-router at a preset frequency.

[0048] Exemplarily, the cloud server may send keep-alive control information to the first sub-router and the second sub-router, causing the first sub-router to send keep-alive information to the second sub-router at a preset frequency, and causing the second sub-router to send keep-alive information to the first sub-router at a preset frequency, maintaining the normal establishment of the session between the first sub-router and the second sub-router, ensuring that the first sub-router and the second sub-router can be accessed at any time, and avoiding the problem of reduced communication real-time performance and communication efficiency due to the need to re-perform network hole punching when communicating after the session is disconnected.

[0049] The technical solution of the embodiment of the present application is to receive the routing network information sent by the sub-router in the cascaded router, and count the number of the sub-routers according to the routing network information; if the number of the sub-routers is at least two, then for any two sub-routers, control the two sub-routers to perform network hole punching; if the network hole punching of the two sub-routers is successful, record the hole punching information to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information. The above solution, when detecting that there are at least two sub-routers, pre-controls at least two sub-routers to perform hole punching and records the hole punching information, so that when the terminal devices under different sub-routers need to communicate, they can directly communicate according to the hole punching information through the pre-punched link, without the need to first perform network hole punching to establish a communication link and then communicate, improving the communication real-time performance and communication efficiency.

[0050] Embodiment 2

[0051] Figure 5 It is a flowchart of a communication method provided by Embodiment 2 of the present application. The embodiment of the present application is optimized based on the above embodiment. For the solutions not described in detail in the embodiment of the present application, refer to the above embodiment. As Figure 5 shown, the method of the embodiment of the present application specifically includes the following steps:

[0052] S210. Receive the routing network information sent by the sub-router in the cascaded router, and count the number of the sub-routers according to the routing network information.

[0053] S220. If the number of the sub-routers is at least two, then for any two sub-routers, control the two sub-routers to perform network hole punching.

[0054] S230. If the network hole punching of the two sub-routers is successful, record the hole punching information.

[0055] S240. Receive the terminal network information sent by at least two terminal devices.

[0056] Exemplarily, if at least two terminal devices are terminal devices under the same sub-router, they can directly communicate through the local area network. If at least two terminal devices are terminal devices under different sub-routers, the terminal network information sent by the two terminal devices can be received. The terminal network information may include the network address of the terminal device, the network address mapped to the sub-router, and the network address of the corresponding parent router, that is, the public network address after network conversion. Exemplarily, as Figure 6 shown, the terminal network information of IPC10 includes the network address 192.168.1.10:4321 of IPC10, the network address 192.168.0.11:4322 mapped to sub-router 1, and the public network address 155.99.25.11:5431 after address conversion. When IPC10 communicates with the cloud server, the port of sub-router 1 used is different from the port used when sub-router 1 communicates with the cloud server. Through different port numbers, the cloud server can identify whether it is the sub-router or IPC10 that is actually communicating currently, so as to execute different solutions discriminatively. The terminal network information of Phone1 is the same. At the same time, the session when the terminal device communicates with the cloud server is recorded on the parent router, including the network address of the cloud server, the communication address of the parent router, and the network address of the sub-router. For example, the session when sub-router 1 communicates with the cloud server is recorded, including the network address of the cloud server, the network address of the parent router, and the network address of the sub-router. The session between IPC10 and the cloud server is recorded on sub-router 1, including the network address of the parent router, the network address of sub-router 1, and the network address of IPC10.

[0057] S250. Determine whether network punching has been performed on the sub-routers corresponding to at least two terminal devices according to the terminal network information and the punching information.

[0058] Exemplarily, for any two of at least two terminal devices, it can be determined whether network punching has been performed on the sub-routers corresponding to at least two terminal devices according to the terminal network information of the two terminal devices and the punching information recorded by the cloud server. For example, assume that the terminal device IPC10 is under sub-router 1 and the terminal device Phone is under sub-router 2. Then it can be determined whether sub-router 1 and sub-router 2 have performed network punching according to the punching information. If network punching has been performed, the punching information of sub-router 1 and sub-router 2 should be recorded in the cloud server.

[0059] In the embodiment of the present application, determining whether network punching has been performed on the sub-routers corresponding to at least two terminal devices according to the terminal network information and the punching information includes:

[0060] Match the network address of the sub-router corresponding to the terminal device included in the terminal network information with the network address of the sub-router in the hole punching information;

[0061] If there is a match between the network address of the sub-router corresponding to the first terminal device and the network address of the first sub-router in the hole punching information among at least two terminal devices, and there is a match between the network address of the sub-router corresponding to the second terminal device and the network address of the second sub-router in the hole punching information, it is determined that network hole punching has been performed between the first sub-router corresponding to the first terminal device and the second sub-router corresponding to the second terminal device.

[0062] Exemplarily, as described in the above embodiment, the terminal network information may include the network address of the terminal device, the network address of the sub-router, and the network address of the parent router. The hole punching information includes the network address of the sub-router and the corresponding network address of the parent router. Then, the network address of the sub-router included in the terminal network information can be matched with the network address of the sub-router in the hole punching information. If there is a first terminal device, the network address of the sub-router in the terminal network information of this terminal device matches the network address of the first sub-router in the hole punching information, and there is a second terminal device, the network address of the sub-router in the terminal network information of this terminal device matches the network address of the second sub-router in the hole punching information, it is determined that the first terminal device is a terminal device under the first sub-router, the second terminal device is a terminal device under the second sub-router, and the first sub-router and the second sub-router have completed network hole punching, indicating that the first terminal device and the second terminal device can directly communicate based on the link of the network hole punching.

[0063] S260. If so, control at least two terminal devices to communicate according to the hole punching information.

[0064] Exemplarily, if the sub-routers corresponding to two terminal devices have completed network hole punching, they can communicate through the hole punching link in the case where communication cannot be performed through the local area network.

[0065] In the embodiments of the present application, controlling at least two terminal devices to communicate according to the hole punching information includes:

[0066] Notify the first sub-router to map the network address of the first terminal device to the network address of the first sub-router, and notify the second sub-router to map the network address of the second terminal device to the network address of the second sub-router;

[0067] Notify the first terminal device and the second terminal device to communicate according to the hole punching information.

[0068] Exemplarily, multiple terminal devices may be connected under a sub-router, and the sub-router does not know which terminal device needs to communicate at this time. The cloud server may notify the sub-router of the specific terminal device that needs to communicate among the connected terminal devices, and map the network address of this terminal device to the network address of this sub-router. In the case where it has been determined that the first terminal device corresponds to the first sub-router, the second terminal device corresponds to the second sub-router, and the first sub-router and the second sub-router have completed network hole punching, the first sub-router may be notified to map the network address of the first terminal device to the network address of the first sub-router, and the second sub-router may be notified to map the network address of the second terminal device to the network address of the second sub-router. So that the sub-router knows which terminal device needs to communicate currently. The first terminal device and the second terminal device are notified to communicate according to the hole punching information, directly using the link established by the network hole punching of the first sub-router and the second sub-router, without the need to waste time on hole punching temporarily.

[0069] In the embodiment of the present application, notifying the first terminal device and the second terminal device to communicate according to the hole punching information includes:

[0070] Sending the network address of the second sub-router to the first terminal device, so that the first terminal device sends communication data based on the network address of the second sub-router;

[0071] Sending the network address of the first sub-router to the second terminal device, so that the second terminal device sends communication data based on the network address of the first sub-router.

[0072] Exemplarily, the network address of the second sub-router may be sent to the first terminal device, and the first terminal device may send communication data to the network address of the second sub-router. Since the first sub-router and the second sub-router have completed network hole punching, the second sub-router can receive the communication data sent by the first sub-router. Generally, the public network address of the second sub-router is sent to the first terminal device. The network address of the first terminal device is sent to the second terminal device, and the second terminal device can send communication data to the network address of the first terminal device. Since the first sub-router and the second sub-router have completed network hole punching, the first sub-router can receive the communication data sent by the second sub-router. Generally, the public network address of the first sub-router is sent to the second terminal device. The order of sending the network addresses is not limited. It may be sent to the first terminal device first, or to the second terminal device first, or sent simultaneously.

[0073] An embodiment of the present application provides a communication method, which receives terminal network information sent by at least two terminal devices; determines whether the sub-routers corresponding to the at least two terminal devices have performed network punching according to the terminal network information and the punching information; if so, controls the at least two terminal devices to communicate according to the punching information. The above solution can determine whether the sub-router corresponding to the terminal device has been network punched when the terminal device needs to communicate. When the network punching is successful, communication is performed through the network punching link, without the need for temporary network punching, saving the time of temporary network punching, thereby improving the real-time performance and communication efficiency of communication between terminal devices under different sub-routers.

[0074] Embodiment III

[0075] An embodiment of the present application is a specific implementation manner of the above embodiment. The embodiment of the present application is optimized based on the above embodiment. For the solutions not described in detail in the embodiment of the present application, refer to the above embodiment. Wherein, Homebase is a router. The method of the embodiment of the present application specifically includes the following steps:

[0076] 1. Add multiple Homebases to the cloud account:

[0077] User A uses the cloud account a to add Homebase1. Homebase1 provides network access for the terminal devices in the first area, such as IPC10, IPC11, etc. At the same time, add Homebase2 under the cloud account a. Homebase2 provides network access for the terminal devices in the second area, such as device IPC20, Phone1, etc. The networking diagram is as Figure 7 shown.

[0078] 2. Punch holes for multiple Homebases:

[0079] 2.1 Homebase actively communicates with the cloud server and uploads the local area network IP + port. The cloud server records the routing network information of Homebase, including the local area network IP + port and the public network IP + port.

[0080] For example: Homebase1 communicates with the cloud server 18.181.0.31:1234, and a session Session:H1-S is established between Homebase1 and the cloud server on the NAT. Homebase20 communicates with the cloud server 18.181.0.31:1234, and a session Session:H2-S is established between Homebase2 and the cloud server on the NAT. At the same time, the network information of Homebase1 (public network: 155.99.25.11:4321 and local area network: 192.168.0.11:4321) and the network information of Homebase2 (public network: 155.99.25.11:4322 and local area network: 10.1.0.22:4321) are saved on the cloud server.

[0081] 2.2 When the cloud service detects that the number of Homebases under the cloud account is greater than 1, it sends the network information of each Homebase to other Homebases respectively, notifying them to punch holes with each other.

[0082] For example: The cloud server sends the network information of Homebase1 (public network: 155.99.25.11:4321 and local area network: 192.168.0.11:4321) to Homebase2. At the same time, the cloud server sends the network information of Homebase2 (public network: 155.99.25.11:4322 and local area network: 10.1.0.22:4321) to Homebase1, and Homebase1 and Homebase2 start to punch holes.

[0083] 2.3 The hole punching between Homebase1 and Homebase2 is successful, and the hole punching information is recorded on both Homebases. The hole punching information of Homebase1 with Homebase2 is recorded: (LAN 192.168.0.11:4321 of Homebase1 corresponds to public network 155.99.25.11:4322 of Homebase2). The hole punching information of Homebase2 with Homebase1 is recorded: (LAN 10.1.0.22:4321 of Homebase2 corresponds to public network 155.99.25.11:4321 of Homebase1). At the same time, the hole punching information Homebase1 (155.99.25.11:4321 / 192.168.0.11:4321) has successfully punched holes with Homebase2 (155.99.25.11:4322 / 10.1.0.22:4321) is recorded on the cloud server.

[0084] 3. Maintenance of hole information after hole punching

[0085] After the two homebases successfully punch holes, they need to periodically send heartbeat packets to each other to maintain the session on the NAT between the two parties and ensure that they can access each other at any time.

[0086] 4. The terminal devices under the two homebases communicate through the punched hole link

[0087] 4.1 Obtain the terminal network information of the terminal device

[0088] After the terminal device accesses the network, it will keep alive with the cloud server and carry the terminal network information during the keep-alive. The cloud server will record the terminal network information. For example Figure 6 As shown, the IPC10 under Homebase1 sends the terminal network information and stores it in the cloud server. The terminal network information sent by Phone1 under Homebase2 will also be stored in the cloud server.

[0089] 4.2 Match the network information

[0090] The cloud server matches the punched hole information under the recorded account to determine whether there are already punched holes.

[0091] For example: The terminal network information stored in the cloud server includes the terminal network information of IPC10 (155.99.25.11:5431, 192.168.0.11:4322, 192.168.1.10:4321). Among them, 192.168.1.10:4321 represents the network address of the terminal, 192.168.0.11:4322 represents the LAN address of the terminal network address mapped to sub-router 1, and 155.99.25.11:5431 represents the public network address after the LAN undergoes network conversion. It also includes the terminal network information of Phone1 (155.99.25.11:5432, 10.1.0.22:4322, 10.1.1.3:4321). Among them, 10.1.1.3:4321 represents the network address of Phone1, 10.1.0.22:4322 represents the LAN address of the Phone1 network address mapped to sub-router 2, and 155.99.25.11:5432 represents the public network address after the LAN undergoes network conversion. Matching with the existing hole punching information: Homebase1 (155.99.25.11:4321 / 192.168.0.11:4321) corresponding to Homebase2 (155.99.25.11:4322 / 10.1.0.22:4321), the "192.168.0.11:4322" in the terminal network information of IPC10 (155.99.25.11:5431, 192.168.0.11:4322, 192.168.1.10:4321) matches the "192.168.0.11:4321" IP address in the hole punching information of Homebase1 (155.99.25.11:4321 / 192.168.0.11:4321), then it is determined that IPC10 is the terminal device under Homebase1. The "10.1.0.22:4322" in the terminal network information of Phone1 (155.99.25.11:5432, 10.1.0.22:4322, 10.1.1.3:4321) matches the "10.1.0.22:4321" IP address in the hole punching information of Homebase2 (155.99.25.11:4322 / 10.1.0.22:4321), then it is determined that Phone1 is the terminal device under Homebase2. Since Homebase1 and Homebase2 are associated in the hole punching information, it indicates that the hole punching of Homebase1 and Homebase2 has been successful, then IPC10 and Phone1 can directly communicate through the hole-punched link.

[0092] 4.3 The cloud server notifies Homebase to use the already hole-punched port

[0093] For example: The cloud server notifies Homebase2 to map the network address (10.1.1.3:4321) of Phone1 to the LAN address (10.1.0.22:4321) of Homebase2, and notifies Homebase1 to map the network address (192.168.1.10:4321) of IPC10 to the LAN address (192.168.0.11:4321) of Homebase1. That is, it notifies Homebase1 that IPC10 currently needs to communicate with other terminals outside the LAN, and the data obtained by Homebase1 through the hole punching link and communicating with the corresponding Homebase of other terminals needs to be returned to IPC10.

[0094] 4.4 The cloud server sends the matched hole punching information to the terminal device

[0095] For example: The cloud server sends the network address (155.99.25.11:4321) of IPC10 to Phone1, so that Phone1 sends communication data to the network address (155.99.25.11:4321) of IPC10. It sends the network address (155.99.25.11:4322) of Phone1 to IPC10, so that IPC10 sends communication data to the network address (155.99.25.11:4322) of Phone1.

[0096] The embodiment of the present application has the same beneficial effects as any of the above embodiments.

[0097] Embodiment 4

[0098] Figure 8 It is a schematic structural diagram of a communication device provided in Embodiment 4 of the present application. The device can execute the communication method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects for executing the method. As Figure 8 shown, the device includes:

[0099] An information receiving module 410, configured to receive the routing network information sent by the sub-router in the cascaded router, and count the number of sub-routers according to the routing network information;

[0100] A network hole punching control module 420, configured to, if the number of sub-routers is at least two, control any two sub-routers to perform network hole punching for any two sub-routers;

[0101] A hole punching information recording module 430, configured to record the hole punching information if the network hole punching of two sub-routers is successful, so as to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information.

[0102] In the embodiments of the present application, the two sub-routers include a first sub-router and a second sub-router;

[0103] Correspondingly, the network hole punching control module 420 includes:

[0104] A routing network information sending unit, configured to send the routing network information of the second sub-router to the first sub-router, and send the routing network information of the first sub-router to the second sub-router;

[0105] A notification unit, configured to notify the first sub-router to perform network hole punching based on the routing network information of the second sub-router, and / or notify the second sub-router to perform network hole punching based on the routing network information of the first sub-router.

[0106] In the embodiments of the present application, the device further includes:

[0107] A keep-alive control information sending module, configured to send keep-alive control information to the first sub-router and the second sub-router, so that the first sub-router sends keep-alive information to the second sub-router at a preset frequency, and the second sub-router sends keep-alive information to the first sub-router at a preset frequency.

[0108] In the embodiments of the present application, the device further includes:

[0109] A terminal network information receiving module, configured to receive terminal network information sent by at least two terminal devices;

[0110] A judgment module, configured to determine whether network hole punching has been performed on the sub-routers corresponding to at least two terminal devices according to the terminal network information and the hole punching information;

[0111] A communication control module, configured to, if so, control at least two terminal devices to communicate according to the hole punching information.

[0112] In the embodiments of the present application, the judgment module includes:

[0113] A matching unit, configured to match the network address of the sub-router corresponding to the terminal device included in the terminal network address with the network address of the sub-router in the hole punching information;

[0114] A network hole punching confirmation module is used to determine that the first sub-router corresponding to the first terminal device and the second sub-router corresponding to the second terminal device have performed network hole punching if there is a match between the network address of the sub-router corresponding to the first terminal device and the network address of the first sub-router in the hole punching information among at least two terminal devices, and there is a match between the network address of the sub-router corresponding to the second terminal device and the network address of the second sub-router in the hole punching information.

[0115] In an embodiment of the present application, the communication control module includes:

[0116] A mapping notification unit is used to notify the first sub-router to map the network address of the first terminal device to the network address of the first sub-router, and notify the second sub-router to map the network address of the second terminal device to the network address of the second sub-router;

[0117] A communication notification unit is used to notify the first terminal device and the second terminal device to communicate according to the hole punching information.

[0118] In an embodiment of the present application, the communication notification unit is specifically used for:

[0119] Send the network address of the second sub-router to the first terminal device, so that the first terminal device sends communication data based on the network address of the second sub-router;

[0120] Send the network address of the first sub-router to the second terminal device, so that the second terminal device sends communication data based on the network address of the first sub-router.

[0121] A communication device provided by an embodiment of the present application can execute a communication method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution of the method.

[0122] Embodiment Five

[0123] Figure 9 Fig. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present application. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present application described herein and / or claimed.

[0124] As Figure 9 shown, the electronic device 10 includes at least one processor 11 and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0125] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0126] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the communication method.

[0127] In some embodiments, the communication method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the communication method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the communication method by any other appropriate means (e.g., by means of firmware).

[0128] The various embodiments of the systems and techniques described above in this specification can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems-on-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from, and transmits data and instructions to, a storage system, at least one input device, and at least one output device.

[0129] The computer programs for implementing the methods of this application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable communication device, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on the remote machine or server.

[0130] In the context of this application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0132] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0133] A computing system can include a client and a server. The client and the server are generally far from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0134] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this application can be executed in parallel, sequentially, or in a different order, as long as the information desired by the technical solution of this application can be achieved, and this is not limited herein.

[0135] The above specific implementation manners do not constitute a limitation on the protection scope of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the protection scope of this application.

Claims

1. A communication method, characterized in that, the method includes: receiving routing network information sent by a sub-router in a cascaded router, and counting the number of sub-routers according to the routing network information; if the number of sub-routers is at least two, then for any two sub-routers, controlling the two sub-routers to perform network hole punching; if the network hole punching of the two sub-routers is successful, recording the hole punching information to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information.

2. The method according to claim 1, characterized in that, the two sub-routers include a first sub-router and a second sub-router; correspondingly, for any two sub-routers, notifying the two sub-routers to perform network hole punching includes: sending the routing network information of the second sub-router to the first sub-router, and sending the routing network information of the first sub-router to the second sub-router; notifying the first sub-router to perform network hole punching based on the routing network information of the second sub-router, and / or notifying the second sub-router to perform network hole punching based on the routing network information of the first sub-router.

3. The method according to claim 1, characterized in that, after recording the hole punching information, the method further includes: sending keep-alive control information to the first sub-router and the second sub-router, so that the first sub-router sends keep-alive information to the second sub-router at a preset frequency, and the second sub-router sends keep-alive information to the first sub-router at a preset frequency.

4. The method according to claim 1, characterized in that, after recording the hole punching information, the method further includes: receiving terminal network information sent by at least two terminal devices; determining whether the sub-routers corresponding to at least two terminal devices have performed network hole punching according to the terminal network information and the hole punching information; if so, controlling at least two terminal devices to communicate according to the hole punching information.

5. The method according to claim 4, characterized in that, determining whether the sub-routers corresponding to at least two terminal devices have performed network hole punching according to the terminal network information and the hole punching information includes: matching the network address of the sub-router corresponding to the terminal device included in the terminal network address with the network address of the sub-router in the hole punching information; if there is a match between the network address of the sub-router corresponding to the first terminal device and the network address of the first sub-router in the hole punching information among at least two terminal devices, and there is a match between the network address of the sub-router corresponding to the second terminal device and the network address of the second sub-router in the hole punching information, it is determined that the first sub-router corresponding to the first terminal device and the second sub-router corresponding to the second terminal device have performed network hole punching.

6. The method according to claim 5, characterized in that, controlling at least two terminal devices to communicate according to the hole punching information includes: Instruct the first sub-router to map the network address of the first terminal device to the network address of the first sub-router, and instruct the second sub-router to map the network address of the second terminal device to the network address of the second sub-router; Instruct the first terminal device and the second terminal device to communicate according to the hole punching information.

7. The method according to claim 6, wherein, Instructing the first terminal device and the second terminal device to communicate according to the hole punching information includes: Sending the network address of the second sub-router to the first terminal device, so that the first terminal device sends communication data based on the network address of the second sub-router; Sending the network address of the first sub-router to the second terminal device, so that the second terminal device sends communication data based on the network address of the first sub-router.

8. A communication device, wherein, The device includes: An information receiving module, configured to receive the routing network information sent by the sub-router in the cascaded router, and count the number of sub-routers according to the routing network information; A network hole punching control module, configured to, if the number of sub-routers is at least two, control any two sub-routers to perform network hole punching for the two sub-routers; A hole punching information recording module, configured to, if the network hole punching of the two sub-routers is successful, record the hole punching information to control the terminal devices under the two sub-routers to communicate according to the hole punching information; wherein, the hole punching information includes the association relationship between the two sub-routers and the routing network information.

9. An electronic device, wherein, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the communication method according to any one of claims 1-7.

10. A computer-readable storage medium, wherein, The computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the communication method according to any one of claims 1-7 when executed by a processor.